package com.ctshk.app.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.system.dto.MainDataStationDTO;
import com.ctshk.rpc.system.req.MainDataStationListReq;
import com.ctshk.rpc.system.req.MainDataStationReq;
import com.ctshk.rpc.system.req.ScenicUpdateStatusReq;
import com.ctshk.rpc.system.req.main.data.StationUpdateStatusReq;
import com.ctshk.rpc.system.service.IMainDataStationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 火车站点主数据 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-04-23
 */
@RestController
@Api(value = "主数据火车站点",tags = "主数据火车站点")
@RequestMapping("/main-data-station")
public class MainDataStationController extends BaseController {
    @DubboReference
    private IMainDataStationService iMainDataStationService;

    @ApiOperation(value = "列表", notes = "列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "列表", operDesc = "列表")
    @PostMapping("/list")
    public Result<PageResponse<MainDataStationDTO>> list(@RequestBody MainDataStationListReq req) {
        return iMainDataStationService.list(req);
    }

    @ApiOperation(value = "详情", notes = "详情")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "详情", operDesc = "详情")
    @GetMapping("/detail/{id}")
    public Result detail(@PathVariable Long id) {
        return iMainDataStationService.detail(id);
    }


    @ApiOperation(value="新增", notes="新增")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增", operDesc = "新增")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataStationReq req){
        return iMainDataStationService.add(req,getCurrentUser(getRequest()));
    }


    @ApiOperation(value="編輯", notes="編輯")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "編輯", operDesc = "編輯")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataStationReq req){
        return iMainDataStationService.update(req,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="修改火车站点状态", notes="修改火车站点状态")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "火车站站点信息主数据", operDesc = "修改火车站站点主数据")
    @PostMapping("/update/status")
    public Result<Integer> modifyStatus(@RequestBody StationUpdateStatusReq stationUpdateStatusReq){
        return  iMainDataStationService.modifyStatus(stationUpdateStatusReq,getCurrentUser(getRequest()));

    }
}
